package cmd

import (
	"time"
)

type UploadOptions struct {
	Override  bool
	UserAgent string
	Timeout   time.Duration
}

const (
	DefaultAgent   = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36"
	DefaultTimeout = 10 * time.Minute
)

type UploadOption func(*UploadOptions)

func buildOptions(opts ...UploadOption) UploadOptions {
	options := UploadOptions{
		UserAgent: DefaultAgent,
		Timeout:   DefaultTimeout,
	}
	for _, opt := range opts {
		opt(&options)
	}
	return options
}

func (s *TaskRunner) withOptions(opts ...UploadOption) *UploadOptions {
	// 使用client的opts作为默认
	options := buildOptions(opts...)
	return &options
}

func Override(b bool) UploadOption {
	return func(o *UploadOptions) {
		o.Override = b
	}
}

func UserAgent(s string) UploadOption {
	return func(o *UploadOptions) {
		o.UserAgent = s
	}
}

func Timeout(d time.Duration) UploadOption {
	return func(o *UploadOptions) {
		o.Timeout = d
	}
}
